#include <MatrixMath.h>
#include <Wire.h>
#include <vector.h>
#include <LSM303DLH.h>
#include <NewSoftSerial.h>
#include <goldelox.h>
#include <alice.h>
#include <Time.h>
#include <DB.h>



// Uncomment the line appropriate for your platform
#define TABLE_SIZE 512 // Arduino 168 or greater

// The number of demo records that should be created.  This should be less 
// than (TABLE_SIZE - sizeof(EDB_Header)) / sizeof(LogEvent).  If it is higher, 
// operations will return EDB_OUT_OF_RANGE for all records outside the usable range.
#define RECORDS_TO_CREATE 2

// Arbitrary record definition for this table.  
// This should be modified to reflect your record needs.



NewSoftSerial uSerial(2,3);
alice sd;
ngc ngc0;
star star0;
objects obj0;
void setup()
{
  Serial.begin(9600);
    sd.init(&uSerial);
  Serial.println("Alice DB Demo");
  Serial.println();
  //sd.about();
  //sd.DBcreate(0, TABLE_SIZE, sizeof(ngc));
  int recno;

sd.DBopen(804352);
  Serial.print("Record Count: "); Serial.println(sd.DBcount()); 
  for (int i=1;i<sd.DBcount();i++)
	{
    sd.DBreadRec(i, DB_REC obj0);
    Serial.print("tile: "); Serial.println(obj0.tile); 
    Serial.print("STARS: "); Serial.print(obj0.stars_from);Serial.print("->");Serial.println(obj0.stars_to);
    Serial.print("MESSIER: "); Serial.print(obj0.messier_from);Serial.print("->");Serial.println(obj0.messier_to);
    Serial.print("NGC: "); Serial.print(obj0.ngc_from);Serial.print("->");Serial.println(obj0.ngc_to);
}
  
sd.DBopen(641024);
  Serial.print("Record Count: "); Serial.println(sd.DBcount()); 
  for (int i=1;i<sd.DBcount();i++)
	{
    sd.DBreadRec(i, DB_REC star0);
    Serial.print("BAYER: "); Serial.println(star0.bayer);
    Serial.print("Costellation: "); Serial.println(star0.costellation);
    Serial.print("RA: "); Serial.println(star0.ra);   
    Serial.print("DE: "); Serial.println(star0.dec);
    Serial.print("MAG: "); Serial.println(star0.mag);    
    Serial.print("Name: "); Serial.println(star0.name); 
}
  
  
  sd.DBopen(635904);
  Serial.print("Record Count: "); Serial.println(sd.DBcount()); 
  for (int i=1;i<sd.DBcount();i++)
	{
    sd.DBreadRec(i, DB_REC ngc0);
    Serial.print("NGC: "); Serial.println(ngc0.ngc_n);
    Serial.print("RA: "); Serial.println(ngc0.ra);   
    Serial.print("DE: "); Serial.println(ngc0.dec);
    Serial.print("Image: "); Serial.println(ngc0.image);    
    Serial.print("Name: "); Serial.println(ngc0.name); 
}

  sd.DBopen(512);
  Serial.print("Record Count: "); Serial.println(sd.DBcount());
for (int i=1;i<sd.DBcount();i++)
	{
    sd.DBreadRec(i, DB_REC ngc0);
    Serial.print("NGC: "); Serial.println(ngc0.ngc_n);
    Serial.print("RA: "); Serial.println(ngc0.ra);   
    Serial.print("DE: "); Serial.println(ngc0.dec);
    Serial.print("Image: "); Serial.println(ngc0.image);    
    Serial.print("Name: "); Serial.println(ngc0.name); 
}
}

void loop()
{
}

